/**
 * Copyright (c) [2025] [AGIROS] 
 * [travoddsgen] is licensed under Mulan PSL v2. 
 * You can use this software according to the terms and conditions of the Mulan PSL v2. 
 * You may obtain a copy of Mulan PSL v2 at: 
 *          http://license.coscl.org.cn/MulanPSL2 
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 
 * See the Mulan PSL v2 for more details.
 */ 

#ifndef syntaxcheckervisitor_h__
#define syntaxcheckervisitor_h__

#include "AstVisitor.h"
#include "Ast.h"
#include <iostream>
#include <string>
#include <map>

class SyntaxCheckerVisitor : public AstVisitor {
public:
    SyntaxCheckerVisitor(const std::vector<std::string>& includePaths) : includePaths_(includePaths) {
    }

    void visit(ASTNode& node) override;
    void visit(ListNode<DefinitionNode*>& node) override;
    void visit(SpecificationNode& node) override;
    void visit(ModuleDclNode& node) override;
    void visit(ScopedNameNode& node) override;
    void visit(ConstDclNode& node) override;
    void visit(ConstTypeNode& node) override;
    void visit(ConstExprNode& node) override;
    void visit(OrExprNode& node) override;
    void visit(XorExprNode& node) override;
    void visit(AndExprNode& node) override;
    void visit(ShiftExprNode& node) override;
    void visit(AddExprNode& node) override;
    void visit(MultExprNode& node) override;
    void visit(UnaryExprNode& node) override;
    void visit(PrimaryExprNode& node) override;
    void visit(LiteralNode& node) override;
    void visit(PositiveIntConstNode& node) override;
    void visit(TypeDclNode& node) override;
    void visit(ConstrTypeDclNode& node) override;
    void visit(TypeSpecNode& node) override;
    void visit(SimpleTypeSpecNode& node) override;
    void visit(TemplateTypeSpecNode& node) override;
    void visit(BaseTypeNode& node) override;
    void visit(SequenceTypeNode& node) override;
    void visit(StringTypeNode& node) override;
    void visit(WideStringTypeNode& node) override;
    void visit(FixedPtTypeNode& node) override;
    void visit(MapTypeNode& node) override;
    void visit(StructDclNode& node) override;
    void visit(StructDefNode& node) override;
    void visit(ListNode<TypeAnnotationNode*>& node) override;
    void visit(TypeAnnotationNode& node) override;
    void visit(MemberNode& node) override;
    void visit(ListNode<MemberNode*>& node) override;
    void visit(ListNode<FixedArraySizeNode*>& node) override;
    void visit(FixedArraySizeNode& node) override;
    void visit(MemberAnnotationNode& node) override;
    void visit(ListNode<MemberAnnotationNode*>& node) override;
    void visit(StructForwardDclNode& node) override;
    void visit(UnionDclNode& node) override;
    void visit(UnionDefNode& node) override;
    void visit(SwitchTypeSpecNode& node) override;
    void visit(ListNode<CaseNode*>& node) override;
    void visit(CaseNode& node) override;
    void visit(ListNode<CaseLabelNode*>& node) override;
    void visit(CaseLabelNode& node) override;
    void visit(UnionForwardDclNode& node) override;
    void visit(EnumDclNode& node) override;
    void visit(ListNode<EnumeratorNode*>& node) override;
    void visit(EnumeratorNode& node) override;
    void visit(TypeDefDclNode& node) override;
    void visit(IncludeDclNode& node) override;

    const std::string& getIncludeFile(IncludeDclNode* node) {
        if (includeFiles_.find(node) == includeFiles_.end()) {
            std::cerr << "can not find include file path for include node " << std::endl;
            exit(-1);
        }
        return includeFiles_[node];
    }
private:
    /** 包含目录 */
    std::vector<std::string> includePaths_;
    /** @brief 所有的引用IDL文件绝对路径 */
    std::map<IncludeDclNode*, std::string> includeFiles_;
};

#endif // syntaxcheckervisitor_h__